#pragma once
#ifndef WORLDENTITY
#define WORLDENTITY

#include <d3dx9.h>

class CWorldEntity
{
protected:
	enum eSide
	{
		eSideNeutral,
		eSidePlayer,
		eSideEnemy
	};

	D3DXVECTOR3 m_position;
	float m_pitch;
	float m_yaw;
	float m_roll;

	D3DXVECTOR3 m_previousPosition;
	float m_previousPitch;
	float m_previousYaw;
	float m_previousRoll;

	int m_gfxIndex;
	eSide m_side;
	float m_speed;
	bool m_detectCollision;
	float m_collisionCost;

	//collision variables
	D3DXVECTOR3 m_minBounds;
	D3DXVECTOR3 m_maxBounds;
	D3DXVECTOR3 m_obbBoundingBox[8];
	D3DXVECTOR3 m_worldBoundingBox[8];
	D3DXVECTOR3 m_worldMinBounds;
	D3DXVECTOR3 m_worldMaxBounds;

	//sound variables
	int m_indexSound;
	DWORD m_lastTimeSoundPlayed;
	unsigned int m_durationSound;

public:
	CWorldEntity(void);
	~CWorldEntity(void);

	virtual void doUpdate(void)=0;
	virtual void doRender(void)=0;

	bool calculBoundingBox();
	void calculOBBBoundingBox();
	void calculBoundingBoxIntoWorldSpace();

	bool checkCollisionWith(CWorldEntity* const);

	//gettors
	int getSide()const;
	D3DXVECTOR3* getWorldMinBounds();
	D3DXVECTOR3* getWorldMaxBounds();
	bool getDetectCollision()const;
	D3DXVECTOR3 getPosition()const;
	float getYaw()const;
	float getDamage()const;
};

#endif
